package com.example.kafka.controller;

import com.example.kafka.service.AsyncProcessSyncCommitService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 演示异步处理同步提交位点的错误示例
 */
@RestController
@RequestMapping("/api/v1/async-process-sync-commit")
@RequiredArgsConstructor
public class AsyncProcessSyncCommitController {

    private final AsyncProcessSyncCommitService service;

    /**
     * 用例1: 异步订单处理 - 同步提交位点
     */
    @PostMapping("/async-order")
    public String processAsyncOrder(@RequestBody String orderData) {
        return service.processAsyncOrder(orderData);
    }

    /**
     * 用例2: 异步支付处理 - 同步提交位点
     */
    @PostMapping("/async-payment")
    public String processAsyncPayment(@RequestBody String paymentData) {
        return service.processAsyncPayment(paymentData);
    }

    /**
     * 用例3: 异步库存更新 - 同步提交位点
     */
    @PostMapping("/async-inventory")
    public String updateAsyncInventory(@RequestBody String inventoryData) {
        return service.updateAsyncInventory(inventoryData);
    }

    /**
     * 用例4: 异步用户注册 - 同步提交位点
     */
    @PostMapping("/async-user-registration")
    public String processAsyncUserRegistration(@RequestBody String userData) {
        return service.processAsyncUserRegistration(userData);
    }

    /**
     * 用例5: 异步日志处理 - 同步提交位点
     */
    @PostMapping("/async-log")
    public String processAsyncLog(@RequestBody String logData) {
        return service.processAsyncLog(logData);
    }
}
